package com.fling.input;

import com.badlogic.gdx.physics.box2d.Contact;
import com.badlogic.gdx.physics.box2d.ContactImpulse;
import com.badlogic.gdx.physics.box2d.ContactListener;
import com.badlogic.gdx.physics.box2d.Manifold;
import com.fling.Constants;
import com.fling.entity.CollisionEntity;


public class CollisionHandler implements ContactListener, Constants {
    @Override
    public void beginContact(Contact contact) {
        if (contact.getFixtureA().getBody().getUserData() instanceof Object
                && contact.getFixtureB().getBody().getUserData() instanceof Object) {

            CollisionEntity objectA = (CollisionEntity) contact.getFixtureA().getBody().getUserData();
            CollisionEntity objectB = (CollisionEntity) contact.getFixtureB().getBody().getUserData();
            objectA.collide(objectB);
            objectB.collide(objectA);
            
        }
    }

    @Override
    public void endContact(Contact contact) {

    }

    @Override
    public void preSolve(Contact contact, Manifold oldManifold) {

    }

    @Override
    public void postSolve(Contact contact, ContactImpulse impulse) {

    }
}
